/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - core/system/io/streams
// Copyright (c) 2014.  All Rights Reserved
//
// File:		AEDiskFileOutStream.cpp
// Author:		Gianluca Belardelli
// Date:		09/10/2014
//
/////////////////////////////////////////////////////////////////////////
#include <AECore.h>

AEDiskFileOutStream::AEDiskFileOutStream( AEFileHandle &fhHandle, AEFileSystemI *lpFileSystem ) : AEFileOutStreamI( lpFileSystem ),
	m_lpFileName( 0L ),
	m_fhFileHandle( fhHandle )
{
}

const char *AEDiskFileOutStream::GetFileName( void )
{
	return m_lpFileName;
}

void AEDiskFileOutStream::SetFileSystem( AEFileSystemI *lpFileSystem )
{
	m_spFileSystem = lpFileSystem;
}

#if defined( AE_PLATFORM_WIN32 )

AEUINT32 AEDiskFileOutStream::Write( const void *lpBuffer, AEINT32 nLen )
{
	BOOL bRes;
	DWORD dwBytes;

	bRes = WriteFile( m_fhFileHandle.hFile, lpBuffer, nLen, &dwBytes, 0L );

	if( bRes )
		return 0;

	return 1;
}

void AEDiskFileOutStream::Close( void )
{
	CloseHandle( m_fhFileHandle.hFile );
}

void AEDiskFileOutStream::Flush( void ) 
{
	FlushFileBuffers( m_fhFileHandle.hFile );
}

#elif defined( AE_PLATFORM_ANDROID )

AEUINT32 AEDiskFileOutStream::Write( const void *lpBuffer, AEINT32 nLen )
{
}

void AEDiskFileOutStream::Close( void )
{
}

void AEDiskFileOutStream::Flush( void ) 
{
}

#endif 
